package com.eight.cloud.payment.common.enums;

import com.eight.cloud.core.global.exception.ParameterException;
import lombok.Getter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @EnumName: PayTypeEnum
 * @Description: 支付方式枚举类
 * @Author: TXC
 * @Date: 2024-12-26 16:26
 **/
@Getter
public enum PayStrategyEnum {
    /**
     * 支付宝支付
     */
    ALI_NATIVE_PAY(PayChannelEnum.ALIPAY, TradeTypeEnum.NATIVE),
    ALI_JSAPI_PAY(PayChannelEnum.ALIPAY, TradeTypeEnum.JSAPI),
    /**
     * 微信支付
     */
    WX_NATIVE(PayChannelEnum.WECHAT, TradeTypeEnum.NATIVE),
    WX_JSAPI(PayChannelEnum.WECHAT, TradeTypeEnum.JSAPI),
    WX_CODEPAY(PayChannelEnum.WECHAT, TradeTypeEnum.CODEPAY),
    /**
     * 银联支付
     */
    UNION_NATIVE_PAY(PayChannelEnum.UNION_PAY, TradeTypeEnum.NATIVE);

    public final PayChannelEnum channel;
    public final TradeTypeEnum type;

    PayStrategyEnum(PayChannelEnum channel, TradeTypeEnum type) {
        this.channel = channel;
        this.type = type;
    }

    public static PayStrategyEnum getEnum(PayChannelEnum channel, TradeTypeEnum type) {
        for (PayStrategyEnum payTypeEnum : PayStrategyEnum.values()) {
            if (payTypeEnum.getChannel().equals(channel) && payTypeEnum.getType().equals(type)) {
                return payTypeEnum;
            }
        }
        throw new ParameterException("支付方式不存在");
    }
}
